<?php

date_default_timezone_set('PRC');
require_once dirname(__FILE__) . './models/HistoryNode.php';

if( isset($_REQUEST["action"]) ){
	if( $_REQUEST["action"] == "submit" ){
		$post = new historynode();
		$post->date = time();
		$post->content = $_REQUEST["content"];
		$post->save();
	}
	
	if( $_REQUEST["action"] == "delete" ){
		$post = historynode::find($_REQUEST["id"]);
		$post->delete();
	}	
}

?>

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php header("Content-type: text/html; charset=utf-8"); ?>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="libs\bootstrap-3.0.3-dist\dist\css\bootstrap.min.css">
	<style>
	  ul.timeline {
		  list-style-type: none;
		  background: url("res/img/version_line.png") repeat-y scroll 120px 0 transparent;
		  margin: 50px 0;
		  padding: 0;
	  }

	  ul.timeline li {
		  position: relative;
		  margin-bottom: 20px;
	  }
	  ul.timeline li .time {
		  position: absolute;
		  width: 90px;
		  text-align: right;
		  left: 0;
		  top: 10px;
		  color: #999;
	  }
	  ul.timeline li .version {
		  position: absolute;
		  width: 290px;
		  text-align: right;
		  left: -200px;
		  top: 30px;
		  font-size: 40px;
		  line-height: 50px;
		  color: #3594cb;
		  overflow: hidden;
	  }
	  ul.timeline li .number {
		  position: absolute;
		  background: url("res/img/version_dot.png") no-repeat scroll 0 0 transparent;
		  width: 56px;
		  height: 56px;
		  left: 97px;
		  line-height: 56px;
		  text-align: center;
		  color: #fff;
		  font-size: 18px;
	  }
	  ul.timeline li.alt .number {
		  background-image: url("res/img/version_dot_alt.png");
	  }
	  ul.timeline li .content {
		  margin-left: 180px;
		  
	  }
	  ul.timeline li .content pre {
		  background-color: #3594cb;
		  padding: 20px;
		  color: #fff;
		  font-size: 13px;
		  line-height: 20px;
	  }
	  ul.timeline li.alt .content pre {
		  background-color: #43B1F1;
	  }
	</style>
  </head>
  <body>
  	<div class="container"> 
		<a href="index.php">进度</a>
		<a href="wanted.php">需求</a>
		<a href="keyword.php">关键字</a>
	</div>
	
    <div class="container" style="padding:15px;">
		<form action="index.php" method="post">
		<div class="form-group">
			<textarea class="form-control" rows="3" name="content" placeholder="输入一条工作进度"></textarea>
		</div>
		
		<input type="submit" value="submit" class="btn btn-primary pull-right">
		<input type="hidden" name="action" value="submit">
		</form>
	</div>
	<div class="container">
	
		<ul class="timeline">
		<?php
		$history_nodes = historynode::find('all');
		foreach ($history_nodes as $key=>$node) { 
			$fmt_date = date('Y-m-d H:i:s', $node->date);
			$content = $node->content;
			$id = $node->id;
		?>
		  <li>
			  <div class="time"><?php echo $fmt_date; ?></div>
			  <!-- 
			  <div class="version">v3.3.1</div>
			  -->
			  <div class="number"><?php echo $key; ?></div>
			  <div class="content">
				<a href="index.php?action=delete&id=<?php echo $id; ?>">
					<button type="button" class="close" aria-hidden="true" style="margin:0 3px;">&times;</button>
				</a>
				<pre><?php echo $content; ?></pre>
			  </div>
		  </li>
		<?php } ?>
		</ul>
	</div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="libs\bootstrap-3.0.3-dist\dist\js\bootstrap.min.js"></script>
	
  </body>
</html>



